package com.test.mytest.saolei.my.swt;

import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;

class RightClick extends MouseAdapter{
    Data minedata;
    Display display;
    Button minebtn;
    Label label1;
    Button start;
    public RightClick(Data minedata,Display display,Button minebtn,Label 
label1,Button start)
    {
        this.minebtn=minebtn;
        this.minedata=minedata;
        this.display=display;
        this.label1=label1;
        this.start=start;
        
    }
    public void mouseDown(MouseEvent e) {
        if (e.button == 3) {
            Image icon=null;
            minedata.resposeRightClick();
            if (minedata.getLeftClickNum() == 0) {
                if(minedata.getRightClickNum()==0)
                {
                    minebtn.setImage(null);
                    minebtn.redraw();
                }
                if (minedata.getRightClickNum() == 1) {
                    Miner.countnum--;
                    label1.setText(Integer.toString(Miner.countnum));
                    if(minedata.isMine())
                        Miner.rightnum++;
                    if(Miner.rightnum==10){
                        ImageData imdt = new ImageData(getClass()
                                .getResourceAsStream("face3.gif"));
                        icon = new Image(display, imdt);
                        start.setImage(icon);
                        Miner.start=false;
                    }
                        
                    ImageData imdt = new ImageData(getClass()
                            .getResourceAsStream("flag.gif"));
                    icon = new Image(display, imdt);
                    minebtn.setImage(icon);
                }
                if (minedata.getRightClickNum() == 2) {
                    Miner.countnum++;
                    if(minedata.isMine())
                        Miner.rightnum--;
                    label1.setText(Integer.toString(Miner.countnum));
                    ImageData imdt = new ImageData(getClass()
                            .getResourceAsStream("ques.gif"));
                    icon = new Image(display, imdt);
                    minebtn.setImage(icon);
                } 
                
            }
        }
    }
}